package com.li.shop.service.Impl;

import com.li.shop.domain.Orders;
import com.li.shop.domain.OrdersExample;
import com.li.shop.mapper.OrdersMapper;
import com.li.shop.service.OrderService;
import io.micrometer.core.instrument.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrdersMapper ordersMapper;

    @Override
    public int save(Orders orders) {
        return ordersMapper.insert(orders);
    }

    @Override
    public List<Orders> show(String id) {
        return ordersMapper.showorders(id);
    }

    @Override
    public int delete(String pid) {
        return ordersMapper.delete(pid);
    }

    @Override
    public List<Orders> show1(String s) {
        return ordersMapper.showorders1(s);
    }
    @Override
    public List<Orders> show2(String id) {
        return ordersMapper.showorders2(id);
    }
    @Override
    public List<Orders> show3(String id) {
        return ordersMapper.showorders3(id);
    }

    @Override
    public int updateByPid(Orders orders) {
        return ordersMapper.updateByPrimaryKey1(orders);
    }

    @Override
    public List<Orders> list(String name, String peisong, String address) {
        OrdersExample example=new OrdersExample();
        example.createCriteria().andUnameLike("%"+name+"").andAddressLike("%"+address+"%").andPeisongLike("%"+peisong+"%");
        List<Orders>orders=ordersMapper.selectByExample(example);

        return orders;
    }

    @Override
    public List<Orders> list2() {
        OrdersExample example=new OrdersExample();
        List<Orders>orders=ordersMapper.selectByExample(example);
        return orders;
    }

    @Override
    public String getRegistMsgByCondition(Date startTime, Date endTime) {

        return ordersMapper.getRegistMsgByCondition(startTime,endTime);
    }

    @Override
    public List<Orders> list() {
        OrdersExample example=new OrdersExample();
        List<Orders>orders=ordersMapper.selectByExample(example);
        return orders;
    }


    @Override
    public List<Orders> findAllOrders(String id) {
        return ordersMapper.findAllOrders(id);//账单明细
    }

    @Override
    public List<Orders> findAllOrders1(String id) {
        return ordersMapper.findAllOrders1(id);
    }

    @Override
    public int deleteOrdermByPrimaryKey(String id) {
        return ordersMapper.deleteByPrimaryKey(id);
    }
}
